home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / texps.lpro < prev    next >
Encoding:
Text File  |  1990-11-20  |  3.5 KB  |  97 lines

  1. % PostScript prolog for using resident fonts.
  2. % No change is made to the encoding scheme, since `virtual fonts' do that
  3. % better. All we do is change the widths so that PostScript positioning
  4. % matches the assumptions of dvips.
  5.  
  6. % The calling sequence defining font foo to be resident font Bar is
  7. %           /foo [wd0 wd1 ... wd255] /Bar mag atsize rf
  8. % where each character width wdi is in pixels,
  9. % mag is the magnification per thousand,
  10. % and atsize is the desired font size in TeX scaled points (sp).
  11.  
  12. %
  13. TeXDict begin
  14. %
  15. /rf {
  16. 655360 div mul Resolution mul 7227 div /PixPerEm exch def % compute pixels/em
  17. % We copy everything but the FID entry of the resident font
  18. % (just as in section 5.7 of the Red Book)
  19. findfont
  20. dup length 1 add dict /newfont exch def
  21.    {1 index /FID ne
  22.       {newfont 3 1 roll put}
  23.       {pop pop}
  24.       ifelse
  25.    } forall
  26. % Now the top entry on the stack is the array of pixel widths.
  27. % We convert them to PostScript's milli-em units, and put them
  28. % in a Metrics dictionary.
  29.   256 dict begin
  30.      newfont /Encoding get
  31.      0 1 255 {
  32.        2 copy get
  33.        3 index 2 index get 
  34.        1000 mul PixPerEm div def pop
  35.      } for
  36.   pop pop
  37.   newfont /Metrics currentdict put end
  38. % Finally we associate the new font with a name like ZZfoo@,
  39. % using conventions identical to those of downloaded bitmap fonts.
  40.    /fontname exch def
  41.    dmystr 2 fontname cvx (@@@@) cvs putinterval  % put name in template
  42.    newname dup newfont definefont
  43.    [PixPerEm 0 0 PixPerEm neg 0 0] makefont def
  44.    fontname { /foo setfont }       %  dummy macro to be filled in
  45.       2 array copy cvx def         %  have to allocate a new one
  46.    fontname load                   %  now we change it
  47.       0 dmystr 6 string copy       %  get a copy of the font name
  48.       cvn cvx put                  %  and stick it in the dummy macro
  49. } bdf
  50.  
  51. %
  52. %   Now here's some oblique hackery... an example of making
  53. %   variants of a resident font look like it is resident.
  54. %   Say, e.g., /Times-Slanted /Times-Roman .167 SlantFont
  55. %   to make /Times-Slanted a font with slant of 1/6;
  56. %   or /Times-Extended /Times-Roman 1.05 ExtendFont
  57. %   to make a font that's 5% wider.
  58. %   Optionally replace the `slant' by `angle ObliqueSlant';
  59. %   note that the ObliqueSlant of Times-Italic is -15.5 (negative).
  60. %
  61. /ObliqueSlant {   % angle ObliqueSlant slant
  62.     dup sin exch cos div neg
  63.     } bdf
  64.  
  65. /SlantFont {      % fontname basefontname slant SlantFont pseudoresfontname
  66.     /foo exch def
  67.     [1 0 foo 1 0 0] TransFont
  68.     } bdf
  69.  
  70. /ExtendFont {     % widtharray fontname basefontname factor ExtendFont
  71.                   %     widtharray' pseudoresfontname
  72.     /foo exch def
  73.     3 2 roll [ exch {foo div} forall ] % divide each width entry by the factor
  74.     3 1 roll [foo 0 0 1 0 0] TransFont
  75.     } bdf
  76.  
  77. % Note: After Times-Slanted is declared once as a SlantFont, you can
  78. % use it again without redeclaring its relation to Times-Roman.
  79. % But this doesn't work with Times-Extended, because you have to
  80. % recompute the widths for each incarnation of Times-Extended.
  81. % In fact, strictly speaking, it doesn't work even with Times-Slanted,
  82. % because the widths are rounded differently at different sizes.
  83. % Therefore dvips repeats the special instructions each time.
  84.  
  85. /TransFont {      % fontname basefontname matrix TransFont pseudoresfontname
  86.     exch findfont exch makefont
  87.     dup length dict /newfont exch def
  88.        {1 index /FID ne
  89.           {newfont 3 1 roll put}
  90.           {pop pop}
  91.        ifelse
  92.        } forall
  93.     dup newfont definefont pop
  94.     } bdf
  95. %
  96. end
  97.